package com.guo.boot.controller;

import com.guo.boot.api.CommonResult;
import com.guo.boot.entity.User;
import com.guo.boot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author HeartGuo
 * @date 2021/12/19 0019 - 18:51
 */
@RequestMapping("/boot")
@ResponseBody
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public CommonResult login(@RequestBody User user){
        String username = user.getUsername();
        String password = user.getPassword();
        user = userService.login(username,password);
        if(user != null){
        		return CommonResult.success("guo,2021/12/19,成功走一遍");
        }else{
        		return CommonResult.validateFailed("failed");
        }
    }
}
